package leetcode_day._2021._202106._2130;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/6/21 23:00
 * 二进制手表
 * 算法：位运算
 * 双重循环，外层循环小时，内层循环分钟
 * 然后算出当前小时和分钟需要亮的灯数
 */
public class _21_401 {
    public static void main(String[] args) {
        System.out.println(Integer.bitCount(12));
    }

    public List<String> readBinaryWatch(int turnedOn) {
        List<String> ans = new ArrayList<>();
        for (int i = 0; i < 12; i++) {
            int a = Integer.bitCount(i);
            for (int j = 0; j < 60; j++) {
                int b = Integer.bitCount(j);
                if (a + b == turnedOn) {
                    String min = j < 10 ? "0" + j : j + "";
                    ans.add(i + ":" + min);
                }
            }
        }
        return ans;
    }

}
